/****** Object: View [dbo].[vw_RealIncome]   Script Date: 2014-01-19 21:49:26 ******/
USE [SHMIS];
GO
IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[vw_RealIncome]'))
BEGIN
DROP VIEW [dbo].[vw_RealIncome];
END
GO

SET ANSI_NULLS ON;
GO
SET QUOTED_IDENTIFIER ON;
GO
CREATE VIEW dbo.vw_RealIncome
AS
   SELECT ar.Customer_Code,
          ar.Contract_Num,
          ar.Serial_Num,
          ar.Customer_Simple_Code,
          ar.Customer_Simple_Name,
          ar.Date,
          ar.Amount,
          ar.Amount_Type,
          ar.Duration_Begin,
          ar.Duration_End,
          ri.Actual_Date,
          ri.Actual_Amount,
          ri.Operate_Status,
          ri.Credit_Comment,
          ri.Comments,
          ri.cre_user,
          ri.cre_date,
          ri.chg_user,
          ri.chg_date,
          ri.verified,
          ri.verify_user,
          ri.deleted
     FROM dbo.HD_AccountReceivable ar
          RIGHT JOIN
          dbo.HD_RealIncome ri
             ON     ar.Customer_Code = ri.Customer_Code
                AND ar.Contract_Num = ri.Contract_Num
                AND ar.Serial_Num = ri.Serial_Num
                AND ar.deleted = '0'
                AND ar.verified = '1'
                AND ar.audited = '1'
                AND ri.verified = '1'
                AND ri.deleted = '0'
GO

